/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.dao.impl;

import com.ivanbiz.dao.StockOpnameDAO;
import com.ivanbiz.helper.HibernateUtil;
import com.ivanbiz.model.Item;
import com.ivanbiz.model.StockOpname;
import org.hibernate.Session;

/**
 *
 * @author Administrator
 */
public class StockOpnameDAOImpl extends GenericDAOImpl implements StockOpnameDAO {

    @Override
    public void saveAndUpdateStockItem(StockOpname stockOpname, Item item) throws Exception {
        try {
            HibernateUtil.beginTransaction();
            Session session = HibernateUtil.getSession();
            session.save(stockOpname);
            session.update(item);
            HibernateUtil.commitTransaction();
        } catch (Exception e) {
            HibernateUtil.rollbackTransaction();
            throw e;
        } finally {
            HibernateUtil.closeSession();
        }
    }
}
